package core.hxl.feign;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

@Component
@FeignClient(value = "contactService",fallback = FeignDemo.FeignDemoFallback.class )
public interface FeignDemo {

    @GetMapping("/api/service/{name}")
    public String getService(@PathVariable("name") String name);

    @GetMapping("/api/service1")
    public String getService1(@RequestParam("name") String name);

    @Component
    class FeignDemoFallback implements FeignDemo{

        @Override
        public String getService(String name) {
            return "hystrix error";
        }

        @Override
        public String getService1(String name) {
            return "error";
        }
    }


}
